/* ************************************************************************
> File Name:     1.c
> Author:        zhfu
> mail:          3346897597@qq.com
> Created Time:  2022年04月27日 星期三 21时48分12秒
> Description:   
 ************************************************************************/
#include"strtok.h"
#include"strtok_r.h"
#include<stdio.h>
#include<stdlib.h>


int main()
{
    char str[] = "root:x::0:root:/root:/bin/bash";
	char *token;

	token = my_strtok(str, ":");
	printf("%s\n", token);
	while ( (token = my_strtok(NULL, ":")) != NULL)
		printf("%s\n", token);
	
    return 0;
}

/*
int main(int argc, char *argv[])
{
	char *str1, *str2, *token, *subtoken;
	char *saveptr1, *saveptr2;
	int j;

	if (argc != 4) {
		fprintf(stderr, "Usage: %s string delim subdelim\n",
			argv[0]);
		exit(EXIT_FAILURE);
	}

	for (j = 1, str1 = argv[1]; ; j++, str1 = NULL) {
		token = my_strtok_r(str1, argv[2], &saveptr1);
		if (token == NULL)
			break;
		printf("%d: %s\n", j, token);

		for (str2 = token; ; str2 = NULL) {
			subtoken = my_strtok_r(str2, argv[3], &saveptr2);
			if (subtoken == NULL)
				break;
			printf(" --> %s\n", subtoken);
		}
	}

	exit(EXIT_SUCCESS);
}
*/
